Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 22: Adding a Background

../ch22/22fig04.gif
Figure 22.4

Backgrounds bound and unbound by touching a red cube or a blue sphere.

22fig04.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Initial background
        Background {
            skyColor [ 0.0 0.2 0.7,  0.0 0.5 1.0,  1.0 1.0 1.0 ]
            skyAngle [ 1.309, 1.571 ]
            groundColor [ 0.1 0.1 0.0,  0.4 0.25 0.2,  0.6 0.6 0.6 ]
            groundAngle [ 1.309, 1.571 ]
        },
    # Alternate backgrounds
        DEF AltBack1 Background {
            skyColor [ 1.0 0.0 0.0,  1.0 0.4 0.0,  1.0 1.0 0.0 ]
            skyAngle [ 1.309, 1.571 ]
            groundColor [ 0.1 0.1 0.0,  0.5 0.25 0.2,  0.6 0.6 0.2 ]
            groundAngle [ 1.309, 1.571 ]
        },
        DEF AltBack2 Background {
            skyColor [ 1.0 0.0 0.8,  0.5 0.0 0.8,  0.0 0.0 0.8 ]
            skyAngle [ 1.309, 1.571 ]
            groundColor [ 0.0 0.0 0.1,  0.0 0.1 0.3,  0.3 0.3 0.6 ]
            groundAngle [ 1.309, 1.571 ]
        },
    # Shapes to act as buttons
        Transform {
            translation -2.0 0.0 0.0
            children [
                Shape {
                    appearance Appearance {
                        material Material {
                            diffuseColor 1.0 0.0 0.0
                        }
                    }
                    geometry Box { }
                },
                DEF TouchBox TouchSensor { }
            ]
        },
        Transform {
            translation 2.0 0.0 0.0
            children [
                Shape {
                    appearance Appearance {
                        material Material {
                            diffuseColor 0.0 0.0 0.8
                        }
                    }
                    geometry Sphere { }
                },
                DEF TouchSphere TouchSensor { }
            ]
        }
    ]
}
ROUTE TouchBox.isActive    TO AltBack1.set_bind
ROUTE TouchSphere.isActive TO AltBack2.set_bind